-- @owner: opentestcase003
-- @date: 2022-07-28
-- @testpoint: dense_rank函数测试，dense_rank()作为子查询结合minus

--step1: 创建表；expect:成功
drop table if exists t1_ustore_function_denserank_0056;
create table t1_ustore_function_denserank_0056(id1 int,id2 int,id3 smallint,id4 int,num1 float,char1 varchar(500)) with (storage_type=ustore);
insert into t1_ustore_function_denserank_0056 values ( 1 , -1 , 2 , 5 , 4041.04329387 , ' a哪吒 ');
insert into t1_ustore_function_denserank_0056 values ( 3 , 3 , 6 , 3 , 4005.70237548 , ' 010012228 ');
insert into t1_ustore_function_denserank_0056 values ( 1 , -1 , 3 , 3 , 4030.1242131 , ' 数字字符字母 ');
insert into t1_ustore_function_denserank_0056 values ( 1 , 4 , 4 , 4 , 4001.87754238 , ' 010012228 ');
insert into t1_ustore_function_denserank_0056 values ( 6 , 34 , 4 , 3 , 4016.94485186 , ' gkj^%$ ( )+_-= ');
insert into t1_ustore_function_denserank_0056 values ( 8 , 1 , 55 , -1 , 4007.07989431 , ' 数字字符字母 ');
insert into t1_ustore_function_denserank_0056 values ( 0 , 3 , 9 , 4 , 4004.05504939 , ' ilhfjejgyhg ');
insert into t1_ustore_function_denserank_0056 values ( 10 , 2 , 1 , 2 , 4020.02593705 , ' ilhfjejgyhg ');
insert into t1_ustore_function_denserank_0056 values ( null , null , 9 , null , 4004.05504939 , null);
insert into t1_ustore_function_denserank_0056 values ( null , null , null , null , null , ' ilhfjejgyhg ');
insert into t1_ustore_function_denserank_0056 values ( null , null , null , null , null , null);

drop table if exists t2_ustore_function_denserank_0056;
create table t2_ustore_function_denserank_0056(id1 int,id2 int,id3 smallint,id4 int,num1 float,char1 varchar(500)) with (storage_type=ustore);
insert into t2_ustore_function_denserank_0056 values ( 1 , 2 , 5 , 0 , 4020.39455016 , ' gkj^%$ ( )+_-= ');
insert into t2_ustore_function_denserank_0056 values ( 2 , 1 , 7 , 1 , 4025.20440658 , ' gkj^%$ ( )+_-= ');
insert into t2_ustore_function_denserank_0056 values ( 2 , 0 , 6 , 1 , 4026.95604291 , null);
insert into t2_ustore_function_denserank_0056 values ( 2 , 2 , 2 , -2 , 4006.6531689 , ' gkj^%$ ( )+_-= ');
insert into t2_ustore_function_denserank_0056 values ( 3 , -1 , 10 , 5 , 4004.55304488 , ' 数字字符字母 ');
insert into t2_ustore_function_denserank_0056 values ( 3 , 22 , 9 , -1 , 4029.44331076 , ' null ');
insert into t2_ustore_function_denserank_0056 values ( 1 , null , 61 , -1 , 4014.64787564 , ' ilhfjejgyhg ');
insert into t2_ustore_function_denserank_0056 values ( 3 , 0 , 19 , 0 , 4016.82235384 , ' 数字字符字母 ');
insert into t2_ustore_function_denserank_0056 values ( 3 , 4 , null , 1 , 4012.94171374 , ' ilhfjejgyhg ');
insert into t2_ustore_function_denserank_0056 values ( 1 , 32 , 7 , 5 , 4018.72393697 , ' gkj^%$ ( )+_-= ');
insert into t2_ustore_function_denserank_0056 values ( 2 , 4 , 12 , 4 , 4006.22864003 , ' ilhfjejgyhg ');
insert into t2_ustore_function_denserank_0056 values ( 3 , -1 , 6 , 20 , 4039.80600787 , ' 数字字符字母 ');
insert into t2_ustore_function_denserank_0056 values ( 2 , 3 , 9 , 11 , 4031.84294921 , ' 数字字符字母 ');

drop table if exists t4_ustore_function_denserank_0056;
create table t4_ustore_function_denserank_0056(col_1 bigint, col_2 timestamp, col_3 bool,col_4 decimal,col_5 clob ,
col_6 interval day to second ,col_7 nchar(30) ,col_8 blob ,col_9 raw(100),col_10 date,
col_11 bytea ,col_12 bytea,col_13 varchar2(800)) with (storage_type=ustore);
drop sequence if exists s_ustore_function_denserank_0056;
create sequence s_ustore_function_denserank_0056 increment by 1 start with 10000;
insert into t4_ustore_function_denserank_0056 values(s_ustore_function_denserank_0056.nextval,to_date('2019-09-05 10:45:42', 'yyyy-mm-dd hh:mi:ss'),'true',3.141592665735674554784786,lpad('abc','50','a@123&^%djgk'),(interval '4 5:12:10.222' day to second(3)),rpad('abc','30','uegc%^4'),'101001010','0faadb9',to_date('1981-2-20', 'yyyy-mm-dd'),'101001010','01010111111110000000000',lpad('jhafd韩子高各机构测','80','ajge'));
insert into t4_ustore_function_denserank_0056 values(s_ustore_function_denserank_0056.nextval,to_date('2019-09-06 10:45:42', 'yyyy-mm-dd hh:mi:ss'),'true',3.141592665735674554784787,lpad('abc','55','a@123&^%djgk'),(interval '4 5:12:10.222' day to second(3)),rpad('ab','30','uegc%^4'),'101010101010','0faadb9',to_date('1981-2-21', 'yyyy-mm-dd'),'1001010101010','01010111111110000000001100000',lpad('jhafd韩子高各机构测','82','ajgedf'));
insert into t4_ustore_function_denserank_0056 values(s_ustore_function_denserank_0056.nextval,to_date('2019-09-07 10:45:42', 'yyyy-mm-dd hh:mi:ss'),'true',3.141592665735674554784788,lpad('abc','100','a@123&^%djgk'),(interval '4 5:12:10.222' day to second(3)),rpad('abc','29','uegc%^4'),'101010101010','0faadb9',to_date('1981-3-20', 'yyyy-mm-dd'),
'1010100101010','010101111111100000000011100000',lpad('jhafd韩子高各机构测','81','ajge'));
insert into t4_ustore_function_denserank_0056 values(s_ustore_function_denserank_0056.nextval,to_date('2019-09-08 10:45:42', 'yyyy-mm-dd hh:mi:ss'),'false',3.141592665735674554784789,lpad('abc','500','a@123&^%djgk'),(interval '4 5:12:10.222' day to second(3)),rpad('abc','28','uegc%^4'),'1010101001010','0faadb9',to_date('1981-3-21', 'yyyy-mm-dd'),
'10101001010111','010101111111100000000000000',lpad('jhafd韩子高各机构测','185','ajge'));
insert into t4_ustore_function_denserank_0056 values(s_ustore_function_denserank_0056.nextval,to_date('2019-09-05 10:45:42', 'yyyy-mm-dd hh:mi:ss'),'true',3.1415926657356745547847861,lpad('abc','20','a@123&^%djgk'),(interval '4 5:13:10.222' day to second(3)),rpad('abc','30','uegc%^4'),empty_blob(),'0faadb9',to_date('1981-2-20', 'yyyy-mm-dd'),'10101001010','01010111111110000000000',lpad('jhafd韩子h高各机构测','80','ajge'));

--step2: dense_rank函数测试，dense_rank()作为子查询结合minus；expect:成功
select id1,id3,id4,dense_rank() over(partition by id1,id4 order by id3 nulls last,num1) f1 from t1_ustore_function_denserank_0056 minus select id2,id3,id4,dense_rank() over(partition by id2,id4 order by id4 desc nulls first,num1) f1 from t2_ustore_function_denserank_0056 order by 1,2,3 limit 10;
select col_1,col_2,col_3,col_8,dense_rank() over(partition by col_2,col_3 order by col_1,col_8 desc) f1 from t4_ustore_function_denserank_0056 minus select col_1,col_2,col_3,col_8,1 from t4_ustore_function_denserank_0056 where col_1 is null;
select col_1,col_2,col_3,col_7,dense_rank() over(partition by col_2,col_3 order by col_1,col_7 desc) f1 from t4_ustore_function_denserank_0056 minus select col_1,col_2,col_3,col_7,1 from t4_ustore_function_denserank_0056 where col_1 is null;

--step3: 清理表；expect:成功
drop sequence s_ustore_function_denserank_0056;
drop table t1_ustore_function_denserank_0056;
drop table t2_ustore_function_denserank_0056;
drop table t4_ustore_function_denserank_0056;
